package 剑指offer;

public class FindFirst {
    public static int FirstNotRepeatingChar(String str) {
        int count = 1;
        int flag = 0;
        if (str.equals("")) {
            return -1;
        }
        out:
        {
            for (int i = 0; i < str.length(); i++) {
                for (int j = 0; j < str.length(); j++) {
                    if (str.charAt(i) == str.charAt(j)) {
                        count--;
                        System.out.println("count" + count);
                    }
                    if (j == str.length() - 1 && count == 0) {
                        flag = i;
                        break out;
                    }
                    if (j == str.length() - 1) {
                        count = 1;
                    }
                }

                if (i == str.length() - 1 && count != 0) {
                    flag = -1;
                }

            }
        }
        return flag;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println(FirstNotRepeatingChar("12313131"));
    }

}
